/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Modelo;

import Modelo.*;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.LinkedList;
import javax.swing.*;

/**
 *
 * @author Alex
 */
public class ModelEstudiosRea implements Serializable{

	Conection con;

    public ModelEstudiosRea(Conection con) {
      this.con=con;
    }
	ResultSet rs;

	

	


 public LinkedList Estudios(String codigo)throws SQLException{
	LinkedList listaEstu=new LinkedList();
	PreparedStatement pstmt=null;
	ResultSet rs=null;
  	try{

  		pstmt=con.getCon().prepareStatement("select * from Estudios where Estudios.Aspirante_Id =" + codigo);
  		rs=pstmt.executeQuery();
  		while(rs.next()){
  			listaEstu.add(Empresa.Load(rs));

  		}
  	}finally{
 		if(rs!=null){
			rs.close();
		}
		if(pstmt!=null){
			pstmt.close();
			pstmt=null;
		}
	}

	return listaEstu;
 }
  public void setNewEstudios(Estudios estu) throws SQLException {
        if(!con.isConnect())
                throw new SQLException("no Hay Conexion");
            PreparedStatement pstmt=null;
            try{
                pstmt=con.getCon().prepareStatement("insert into Estudios values(?,?,?,?,?)");
                pstmt.setString(1, estu.getLugar());
                pstmt.setString(2, estu.getTitulo());
                pstmt.setString(3, estu.getDirecion());
                pstmt.setString(4, estu.getTelefono());
                pstmt.setString(5, estu.getAños());
		
                
		pstmt.executeUpdate();

                }finally
                {
                    if( pstmt!=null )
                    pstmt.close();
                }


    }
}// fin clase model
